import moment from 'moment';

import { Popover } from 'antd';

const styles = {
  width: 75,
  height: 75,
  borderRadius: 6,
  backgroundSize: 'cover',
  backgroundPosition: 'center',
  backgroundRepeat: 'no-repeat',
}

const renderImage = pathname => (
    <Popover placement="right" title="大图预览"  content={<img src={pathname} style={{maxWidth: 1000, maxHeight: 750}} />
  } >
  <div style={{...styles, backgroundImage: `url(${pathname})`}} /> <
  /Popover>
);

export default [{
  title: '广告图片',
  dataIndex: 'cover',
  width: 90,
  render: pathname => renderImage(pathname),
}, {
  title: '跳转链接',
  dataIndex: 'pathname',
}, {
  title: '关联小程序 APPID',
  dataIndex: 'appId',
}, {
  title: '下架日期',
  dataIndex: 'endAt',
  sorter: true,
  render: val => <span style={{whiteSpace: 'nowrap'}}>{moment(val).format('YYYY-MM-DD HH:mm')}</span>,
}];